import { Application } from 'egg';
import { Instance } from 'sequelize';

export interface DetailsAttributes {
  title: string;
  description: string;
  status: string;
  brand_status: string;
  type: string;
  open_time: string;
  area: string;
  floor: string;
  product_line: string;
  city: string;
  address: string;
}

export interface DetailsInstance extends Instance < DetailsAttributes >, DetailsAttributes {
  id?: number;
  createdAt: Date;
  updatedAt: Date;
}

export default (app: Application) => {

  const { TEXT } = app.Sequelize;

  const Details = app.model.define< DetailsInstance, DetailsAttributes >('Details', {
    title: TEXT,
    description: TEXT,
    status: TEXT,
    brand_status: TEXT,
    type: TEXT,
    open_time: TEXT,
    area: TEXT,
    floor: TEXT,
    product_line: TEXT,
    city: TEXT,
    address: TEXT,
  });

  Details.associate = () => {
    Details.belongsTo(app.model.Lists);
  };

  return Details;
};